using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class FeeType : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            // New connection
            Connection newCon = new Connection();
            SqlConnection con = newCon.ConStr;

            // open conneciton
            con.Open();

            // prepare command
            SqlCommand cmd = new SqlCommand("insert into FeeType values(@First , @Second , @Fee)", con);

            cmd.Parameters.AddWithValue("First", DropDownList1.SelectedItem.Value);
            cmd.Parameters.AddWithValue("Second", DropDownList2.SelectedItem.Value);

            double temp = 0;
            try
            {
                Double.TryParse(TextBox1.Text, out temp);
            }
            catch (Exception ex)
            {
                Label1.Text = ex.Message;
                return;
            }

            cmd.Parameters.AddWithValue("Fee", temp);

            // execute query
            cmd.ExecuteNonQuery();

            // reload gridview
            GridView1.DataBind();

            // close connection
            con.Close();
            Label1.Text = "";
        }
        catch (Exception ex)
        {
            Label1.Text = "Cannot insert new record: " + ex.Message;
        }

    }
}
